#!/bin/sh

WDIR=`dirname $0`
cd "${WDIR}"
MAINDIR=`pwd -P`
MEDIA=$(grep MEDIA_URL settings.py | cut -d "'" -f2)

for rst in lpx/media/doc/*
do
    SOURCE=`basename $rst`
    TMP=`basename $rst .rst`
    LOC=`echo $TMP | cut -d "-" -f2`
    HTML="lpx/templates/$TMP.html"
    FILE="gendoc.$$.tmp"
    rst2html.py -g -d -t -s --link-stylesheet --source-url="$MEDIA/doc/$SOURCE" $rst $FILE
    echo '{% extends "base_other.html" %}{% load i18n %}{% block content %}' > $HTML
    cat $FILE | sed '1,10d' | sed 'N;$!P;$!D;$d' >> $HTML
    echo "{% endblock %}" >> $HTML
    rm -f $FILE
done
